<div class="window">
  <div class="window_content">
    <h4><a href="#" class="jqmClose"><img src="images/close.gif" alt="" height="16px" width="16px" /></a>选择模块</h4>
    <div id="protocol">
      <table style="margin-top:20px;">
        <tr>
          <td width="23%"><strong>博客名称</strong>：</td>
          <td width="77%"><input name="info[spacename]" id="spacename" type="text" value="{$spacename}" /></td>
        </tr>
      </table>
      <table style="margin-top:20px;">
        <tr>
          <th>模块</th>
          <th>操作管理</th>
        </tr>
        {loop $block $api}
        <tr>
          <td>{$api[name]}</td>
          <td>
		  {if $api[installed]}
		  <a href="javascript:void();" onclick="blockdel({$api[apiid]})">删除</a> 
		  {else}
          <a href="javascript:void();" onclick="blockadd({$api[apiid]})">增加</a>
		  {/if}
		  </td>
        </tr>
        {/loop}
      </table>
    </div>
  </div>
</div>
<script language="javascript">
	var apiid;
	function blockadd(apiid)
	{
		$.post("{$M[url]}block.php", {action:'edit', userid:{$_userid}, blockid: apiid}, function(data) {
			window.location.reload();
		});
	}
	function blockdel(apiid)
	{
		$.get("{$M[url]}block.php", {action:'del', userid:{$_userid}, blockid: apiid}, function(data) {
			window.location.reload();
		});
	}
	
	$('#spacename').blur(function()
	{
		$('#err').hide();
		if(Common.strlen($('#spacename').val()) > 30)
		{
			$('#spacename').after('<font color="red" id="err">空间名称不得大于30个字符</font>');
			return false;
		}
		$.post("{$M[url]}block.php", {action:'editspacename', spacename:$('#spacename').val(), userid:{$_userid}}, function(data) {
		});
		$("#logo > h1").html($('#spacename').val());
	});
</script>